using System;
using UnityEngine;
using UnityEngine.UI;
using Voodoo.Pattern;

public class UIManager : SingletonMB<UIManager>
{
	public GameObject MainCanvas;

	public GameObject MainMenuCanvas;

	public GameObject ShopCanvas;

	public CanvasGroup AllUI;

	public GameObject FuelIndicator;

	public Button skinsBtn;

	public Button upgradesBtn;

	public Button playBtn;

	public Button prestigeBtn;

	public bool canClickTriggers;

	public GameObject prestigePanel;

	public GameObject skinShop;

	public GameObject prestigeShop;

	private bool gameOn;

	private async void Awake()
	{
	}

	private void Start()
	{
		GameManager instance = SingletonMB<GameManager>.Instance;
		instance.OnGameStart = (Action)Delegate.Combine(instance.OnGameStart, new Action(GameStarted));
		GameManager instance2 = SingletonMB<GameManager>.Instance;
		instance2.OnGameEnd = (Action)Delegate.Combine(instance2.OnGameEnd, new Action(GameEnded));
	}

	private void GameStarted()
	{
		gameOn = true;
	}

	private void GameEnded()
	{
		gameOn = false;
	}

	public void HideRightBtns()
	{
		playBtn.gameObject.SetActive(value: false);
		prestigeBtn.gameObject.SetActive(value: false);
	}

	public void ShowRightBtns()
	{
		playBtn.gameObject.SetActive(value: true);
		prestigeBtn.gameObject.SetActive(value: true);
	}

	public void HideLeftBtns()
	{
		FuelIndicator.SetActive(value: false);
		skinsBtn.gameObject.SetActive(value: false);
		upgradesBtn.gameObject.SetActive(value: false);
		HideRightBtns();
		canClickTriggers = false;
	}

	public void ShowLeftBtns()
	{
		FuelIndicator.SetActive(value: true);
		skinsBtn.gameObject.SetActive(value: true);
		upgradesBtn.gameObject.SetActive(value: true);
		ShowRightBtns();
		canClickTriggers = true;
	}

	private void Update()
	{
		if (!SingletonMB<GameManager>.Instance.AnyWindowActive && !gameOn)
		{
			if (playBtn.isActiveAndEnabled && Singleton<InputController>.Instance.X)
			{
				playBtn.onClick.Invoke();
			}
			if (prestigeBtn.isActiveAndEnabled && Singleton<InputController>.Instance.Y)
			{
				prestigeBtn.onClick.Invoke();
			}
			if (skinsBtn.isActiveAndEnabled && Singleton<InputController>.Instance.RTrigger)
			{
				skinsBtn.onClick.Invoke();
			}
			if (upgradesBtn.isActiveAndEnabled && Singleton<InputController>.Instance.LTrigger)
			{
				upgradesBtn.onClick.Invoke();
			}
		}
	}

	public void ShowMainUI()
	{
		MainCanvas.SetActive(value: false);
		MainMenuCanvas.SetActive(value: false);
		ShopCanvas.SetActive(value: false);
	}

	public void HideMainUI()
	{
		MainCanvas.SetActive(value: true);
		MainMenuCanvas.SetActive(value: true);
		ShopCanvas.SetActive(value: true);
	}

	internal void HideAllUI()
	{
		AllUI.alpha = 0f;
	}
}
